<template>
  <div class="21">
      <div class="header">
        <span>{{title}}</span>
        <a @click="$router.back(-1)" class="return"></a>
      </div>
      <div style="height: 1rem;"></div>
      
      <div class="sl">
        <div class="sl_box">
          <p class="deposit">保证金</p>
        </div>
      </div>
      
      <div class="sl">
        <div class="sl_box sl_box1">         
          <input type="number" readonly="readonly" v-model="deposit1"/>
        </div>
        <div class="sl_box sl_box1">         
          <input type="password" placeholder="请输入支付密码" v-model="password"/>
        </div>
      </div>
             
      <div class="an" v-if="is_show">
        <button type="submit" :style="background" @click="next">提交审核</button>
      </div>
      <div class="an" v-else>
      <button type="submit" :style="background" @click="next1">取消商家模式</button>
      </div>
      <div style="height:1.333333rem"></div>
        <!-- <Tabbar :idx="3"/> -->
  </div>    
    
</template>

<script>
// @ is an alias to /src
import Tabbar from '@/views/public/Tabbar.vue'
import { setTimeout } from 'timers';

export default {
  name: 'asset',
  components: {
    Tabbar
  },
   data() {
    return {
      password: "",      
      is_show:true,
      deposit1:"",
      background:{background:"#ccc"},
      title:"商家认证",
      aid:""
    }
  },
  created:function(){
      this.$axios.post("/index/apply/index",)
      .then(res => {
        if(res.data.code==0){
          this.deposit1=res.data.info.apply_store;
          if(res.data.info.user.is_store == 1){
            this.is_show =! this.is_show;   
            this.aid=res.data.info.user.aid     
          }          
        }
      });
  },
  mounted () {
      
  },
  methods: {
    
    

    next() {

      if (!this.password)
        return this.$createToast({ txt: "请输入支付密码", type: "txt" }).show();

      this.$axios
        .post("/index/apply/subApply", {
          trad_password: this.password          
        })
        .then(res => {
          if (res.data.code == 0) {
            this.$createToast({ txt: res.data.msg, type: "txt" ,time:1200}).show();            
            setTimeout(()=>{
              this.$router.back(-1);
            },1200)            
          } else {            
            this.$createToast({ txt: res.data.msg, type: "txt" ,time:1200}).show();            
          }
        });
    },

    next1() {

      if (!this.password)
        return this.$createToast({ txt: "请输入支付密码", type: "txt" }).show();

      this.$axios
        .post("/index/apply/delstore", {
          trad_password: this.password,
          aid:this.aid
        })
        .then(res => {
          if (res.data.code == 0) {
            this.$createToast({ txt: res.data.msg, type: "txt" ,time:1200}).show();            
            setTimeout(()=>{
              this.$router.back(-1);
            },1200)            
          } else {            
            this.$createToast({ txt: res.data.msg, type: "txt" ,time:1200}).show();            
          }
        });
    }
    
  },
  watch:{
    password(value){
      value?this.background={background:"#F77710"}:
      this.background={background:"#ccc"}
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less">
 
    .header{
      width: 100%;
        height: 1rem;
        line-height: .9rem;
        background: #fff;
        position: fixed;
        top: 0;
        left: 0;
        z-index: 999;        
    }
    .header span {
      font-size: 0.45rem;
      line-height: 1rem;
      font-weight: bold;
      color: #333;
      text-align: left;
      position: absolute;
      left: 0;
      top: 0;
      padding-left: 1rem;
    }
    .return {
        background: url(../../assets/index05.png) no-repeat center;
        background-size: auto 50%;
        width: 1rem;
        height: 1rem;
        position: absolute;
        left: 0;
        top: 0;
    }    
    .sl{
      width: 100%;
      height: 1.2rem;
      margin-top: .3rem;
      background: #fff;
    }
  
    .sl_box{
      width: 90%;
      height: 1.2rem;
      margin: auto;
      overflow: hidden;
      .deposit{
        color: #F77710;
      }
    }
      .sl_box1{
            margin-bottom: 0.3rem;
    }
    .sl_box p,.sl_box select{
      float: left;
    }
    .sl_box p{
      font-size: .4rem;
      color: #333;
      line-height: 1.2rem;
    }
    .sl_box select{
      float: right;
      border-radius: .05rem;
      width: 2.0rem;
        height: .53rem;
        background: #03BE87;
        color: #fff;
        font-size: .35rem;
        border: 1px solid #03be87;
        margin-top: .25rem;
    }
    .sl_box img,.sl_box input{
      float: left;
    }
    .sl_box img{
      width: 5%;
      display: block;
      margin-top: .3rem;
    }
    .sl_box input{
      width: 92%;
      margin-left: 3%;
      border: 0;
      font-size: .35rem;
      line-height: 1.2rem;
      border: 1px solid #F9FAFC;
    }
    .an{
      width: 8.6rem;
      margin: auto;
      height: 1rem;
    }
    .an button{
      width: 90%;
      height: 1rem;
      text-align: center;
      font-size: .35rem;
      line-height: 1rem;
      color: #fff;
      background: #F77710;
      border-radius: .1rem;
      border: 0;
      position: absolute;
      left: 50%;
      bottom: 5%;
      transform:translate(-50%)
    }
    .sqxy{
      width: 90%;
      height: 1rem;
      margin: auto;
      display: flex;
    }
    .sqxy input{
      width: .35rem;
      height: .35rem;
      margin-top: .3rem;
    }
    .sqxy p{
      font-size: .35rem;
      color: #333;
      line-height: 1rem;
      margin-left: .1rem;
    }
    .sqxy p a{
      color: #03BE87;
    }
    
</style>

